import {Pipe, PipeTransform} from "@angular/core";
/**
 * Created by Administrator on 2017/3/28.
 */
@Pipe({name: 'yaerType'})
export class YearTypePipe implements PipeTransform {
    transform(value: any): string {
        let result: string = "-";
        for (let type of this.getTypes()) {
            if (type.value == value) {
                return type.name;
            }
        }
        return "未知"
    }


    types: any = []


    getTypes(): any {
        this.types = []
        let startYear = 2010;
        let endYear = 2022;
        for (var i = startYear; i < endYear; i++) {
            this.types.push({
                name: i + "年",
                value: i
            })
        }
        return this.types
    }
}